import axios from "./http";
const server_10011 = "http://47.92.107.19:10011/";

export function getAqiAndApi(params, callback) {
  axios
    .post(server_10011 + "/getAqiAndApi", {
      pm25: params.pm251,
      pm10: params.pm101,
      so2: params.so21,
      no2: params.no21,
      co: params.co1,
      o3: params.o31
    })
    .then(res => {
      if (res.data.success) {
        callback(res.data.data);
      }
    });
}

export function doubleGetAqiAndApi(params, callback) {
  axios
    .all([
      axios.post(server_10011 + "/getAqiAndApi", {
        pm25: params.pm251,
        pm10: params.pm101,
        so2: params.so21,
        no2: params.no21,
        co: params.co1,
        o3: params.o31
      }),
      axios.post(server_10011 + "/getAqiAndApi", {
        pm25: params.pm252,
        pm10: params.pm102,
        so2: params.so22,
        no2: params.no22,
        co: params.co2,
        o3: params.o32
      })
    ])
    .then(res => {
      if (res[0].data.success && res[1].data.success) {
        callback(res[0].data.data, res[1].data.data);
      }
    });
}
